package com.democxy.front;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.democxy.common.baseData.ResponeData;
import com.democxy.modules.cms.api.ArticleService;
import com.democxy.modules.cms.entity.Blogs;
import com.github.pagehelper.PageInfo;

@Controller
public class BlogController {

	@Autowired
	private ArticleService articleService;
	
	
	@RequestMapping("/front/index.html")
	public String index(Model model) {
		return "front/bblog/index";
	}
	
	@RequestMapping(value = "/front/blogs/{id}.html", method = RequestMethod.GET)
	public String getById(@PathVariable("id") String id,Model model){
		ResponeData<Blogs> byId = this.articleService.getById(id);
		model.addAttribute("blog", byId.getData());
		return "front/bblog/info";
	}
	
	
	@RequestMapping("/front/list.html")
	public String list(Model model,Blogs blogs) {
		model.addAttribute("typeId",blogs.getTypeId());
		ResponeData<PageInfo<Blogs>> responeData = this.articleService.list(blogs);
		PageInfo<Blogs> data = responeData.getData();
		model.addAttribute("pageInfos", data);
		return "front/bblog/list";
	}
	
	
	
}
